// v-newDown 用于多文件文件list下载
//param:(piclist:路径集合，picUrl,picName)
//支持按需引入
export default {
  bind(el, binding) {
    el.addEventListener('click', () => {
      console.log(binding.value)
      if (binding.value.picList == 0 || !binding.value) return
      let pictrues = binding.value.picList

      for (let i = 0; i < pictrues.length; i++) {
        let a = document.createElement('a')
        let url = JSON.parse(JSON.stringify(pictrues[i][binding.value.picUrl]))
        let name = JSON.parse(JSON.stringify(pictrues[i][binding.value.picName]))
        fetch(url).then(res => res.blob()).then(blob => {
          console.log(blob)
          a.href = URL.createObjectURL(blob)
          console.log(a.href)
          a.download = name // 下载文件的名字
          document.body.appendChild(a)
          a.click()
        })

      }

    })
  }
}